<!DOCTYPE html>
<html>
<head>
    <title>{$platform.name}</title>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
    <!--引用layui弹框插件-->
    <script src="/static/layui/layui.all.js"></script>
    <script src="/static/layui/layui.js"></script>
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/lay/modules/layer.js"></script>

    <!--弹框js-->
    <script src="/static/js/yii.js"></script>

    {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    <link href="/static/css/default/public.css" rel="stylesheet"/>
    {/if}

    <script type="text/javascript" src="/static/js/Calendar.js"></script>

    <script type="text/javascript" src="https://mapapi.qq.com/web/mapComponents/geoLocation/v/geolocation.min.js"></script>
    <script charset="utf-8" src="https://map.qq.com/api/gljs?libraries=tools&v=1.exp&key=Y5IBZ-WT4KU-OLYVW-B77GD-IBUUJ-OFFDZ"></script>
</head>
<body>
<style>
    html, body{background-color:#FFF!important;}
    .modal-body{background-color:#fff;padding:15px}
    .page-header{margin-top:15px!important;}
    .add_button{border-top:1px solid #eee;padding-top:15px;}
    .config_img {
        height:65px;
        margin-top: 15px;
    }
    .layui-form-pane .layui-form-label{font-size:12px!important;}
    .modal-body{display: inline-block;padding-bottom:78px;}

    #tip{
        z-index: 9999;
        width:230px;padding-right:0px!important;
        position: absolute;
        top:20px;
        right:20px;
        z-index:9999;
    }
    #tip input{border:1px solid #e3e3e3;line-height:25px;padding:0px 5px}
    #tip span{background-color:#0b6fff;line-height:27px;display: inline-block;float: right;color: #FFFFFF;padding:0px 10px}
    .searachList{
        width:230px;
        background-color: #fff;
        padding-left: 10px;
        position: absolute;
        font-size: 12px;
        right:20px;
        top:44px;
        border-radius: 3px;
        border: 1px solid #ccc;
        z-index:9998;
        max-height:200px;
        overflow: hidden;overflow-y: auto;
    }
    .searachList span{
        width:100%;
        display: inline-block;
        line-height:25px;
    }
    .searachList .list{
        border-bottom: 1px #cccccc dashed;
        display: inline-block;width:100%;
    }


    .geographic input{width:100px!important;float: left;margin-right:15px;}
</style>

<div class="modal-body">

    <fieldset class=" layui-field-title" >
        {if condition="$detail.id>0"}
           <legend>编辑项目</legend>
        {else/}
           <legend>添加项目</legend>
        {/if}
     
    </fieldset>


    <form class="layui-form layui-form-pane form-horizontal" action="" name="layui-form">
        <div class="layui-form-item layui-col-md4">
            <label class="layui-form-label">*项目名称</label>
            <div class="layui-input-block">
                <input type="text" name="title" placeholder="项目名称" class="layui-input" value="{$detail.title}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">监控直播地址:</label>
            <div class="layui-col-md6">
                <input type="text" name="live_url" placeholder="监控直播地址" class="layui-input" value="{$detail.live_url}">
            </div>
        </div>

        <div class="layui-form-item layui-col-md12">
            <label class="layui-form-label">设备序列号</label>
            <div class="layui-col-md2">
                <input type="text" name="deviceSerial" class="layui-input" placeholder="设备序列号" value="{$detail.deviceSerial}" >
            </div>

            <label class="layui-form-label layui-col-md-offset1">通道号</label>
            <div class="layui-col-md2">
                <input type="text" name="channelNo" class="layui-input" placeholder="通道号"  value="{$detail.channelNo}" >
            </div>
        </div>

        <div class="layui-form-item layui-col-md4">
            <label class="layui-form-label">拟选址</label>
            <div class="layui-input-block">
                <input type="text" name="address" placeholder="选址" class="layui-input"  value="{$detail.address}">
            </div>
        </div>

        <div class="layui-form-item layui-col-md4">
            <label class="layui-form-label">落地可能性</label>
            <div class="layui-input-block">
                <input type="number" name="possibility" placeholder="落地可能性" class="layui-input"  value="{$detail.possibility}">
            </div>
        </div>



        <!--地图标点-->
        <!--<div class="layui-form-item">-->
            <!--<label class="layui-form-label wd-110">地图标识:</label>-->
            <!--<div class="col-sm-5 geographic">-->
                <!--<input type="text" class="form-control" name="lng" id="lng"  value="{$detail.lng}" >-->
                <!--<input type="text" class="form-control" name="lat" id="lat" value="{$detail.lat}" >-->
            <!--</div>-->
        <!--</div>-->

        <!--<div class="layui-form-item" style="position: relative;width:600px;margin-left:60px;">-->
            <!--<div id="container" class="map" tabindex="0" style="height:300px;width:100%;"></div>-->
            <!--<div id='tip'>-->
                <!--<input type="text" id="search" value="" placeholder="输入关键字搜索地址"/>-->
                <!--<span>搜索</span>-->
            <!--</div>-->
            <!--<div class="searachList"></div>-->
        <!--</div>-->

        <!--<div id="info" style="display: none">-->
            <!--<h4 id="txt"></h4>-->
            <!--<p>当前中心点：<span id="position"></span></p>-->
        <!--</div>-->
        <!--地图标点-->


        <div class="layui-form-item layui-col-md4">
            <label class="layui-form-label">缩略图:</label>
            <div class="layui-col-md7">
                <div class="input-group ">
                   
                    <input type="hidden" id="thumb" name="thumb" class="layui-input" autocomplete="off" value="{$detail.thumb}">
                  
                    <span class="input-group-btn">
                        <button class="btn btn-default" id="upload" type="button" data-original-title="" title="">选择图片</button>
                    </span>
                </div>

                {if condition="$detail['thumb'] eq ''"}
                <img class="config_img thumb" src="/static/images/nopic-107.png" >
                {else/}
                <img class="config_img thumb" src="{$detail.thumb}" >
                {/if}
            </div>
        </div>

        <div class="layui-form-item layui-col-md12">
            <label class="layui-form-label">责任单位</label>
            <div id="duty_unit" class="demo-transfer"></div>
        </div>
        <div class="layui-form-item layui-col-md12">
            <label class="layui-form-label">责任人</label>
            <div id="duty_person" class="demo-transfer"></div>
        </div>

        <div class="layui-form-item layui-col-md12">
            <label class="layui-form-label">服务领导</label>
            <div id="leader" class="demo-transfer"></div>
        </div>


        <div class="layui-form-item layui-col-md12">
            <label class="layui-form-label">投资额度</label>
            <div class="input-group col-xs-2" style="float: left">
                <input type="number" class="layui-input" name="investment" placeholder="总投资" value="{$detail.investment}">
                <span class="input-group-addon">万元</span>
            </div>

             <label class="layui-form-label layui-col-md-offset1">项目类别</label>
            <div class="input-group col-xs-6" style="float: left">
                {volist name="pro_type" id="vo" }
                <input type="checkbox" name="project_type[]" value="{$vo.value}" title="{$vo.title}" <?php if(in_array($vo['value'],$detail['project_type'])){ ?> checked="" <?php }?>>
                {/volist}
            </div>
        </div>



        <div class="layui-form-item layui-col-md12">
            <label class="layui-form-label">通过论证会时间</label>
            <div class="layui-col-md2">
                <input type="text" name="cardMeeting" class="layui-input test-item11" placeholder="通过论证会时间" value="{$detail.cardMeeting}" onClick="new Calendar().show(this);" >
            </div>

            <label class="layui-form-label layui-col-md-offset1">计划签约时间</label>
            <div class="layui-col-md2">
                <input type="text" name="signTime" class="layui-input test-item11" placeholder="计划签约时间" value="{$detail.signTime}" onClick="new Calendar().show(this);" >
            </div>
        </div>

        <div class="layui-form-item layui-col-md12">
            <label class="layui-form-label">投资人</label>
            <div class="layui-col-md2">
                <input type="text" name="Investor" class="layui-input test-item1" placeholder="投资人" value="{$detail.Investor}" >
            </div>

            <label class="layui-form-label layui-col-md-offset1">实际签约时间</label>
            <div class="layui-col-md2">
                <input type="text" name="actualsignTime" class="layui-input test-item1" placeholder="实际签约时间" onClick="new Calendar().show(this);" value="{$detail.actualsignTime}" >
            </div>
        </div>

        <div class="layui-form-item layui-col-md12">
            <label class="layui-form-label">所属产业</label>
            <div class="layui-col-md2">
                <select name="IndustrialChain">
                    <option value="0">请选择</option>
                    {volist name="IndustrialChain" id="vo" }
                    <option value="{$vo.value}" {if condition="$detail['IndustrialChain'] eq $vo['value']"} selected {/if}>{$vo.title}</option>
                    {/volist}
                </select>
            </div>

            <label class="layui-form-label layui-col-md-offset1">签约进度</label>
            <div class="input-group col-xs-2" style="float: left">
                <input type="number" class="layui-input" name="progress" placeholder="签约进度" value="{$detail.progress}">
                <span class="input-group-addon">%</span>
            </div>
        </div>



		<div class="layui-form-item layui-col-md12">
            <label class="layui-form-label">业主联系人</label>
            <div class="input-group layui-col-md2" style="float: left">
                <input type="text" class="layui-input" name="project_chief" placeholder="业主联系人" value="{$detail.project_chief}" >
            </div>


            <label class="layui-form-label layui-col-md-offset1">联系人电话</label>
            <div class="input-group layui-col-md2" style="float: left">
                <input type="text" class="layui-input" name="project_phone" placeholder="联系人电话" value="{$detail.project_phone}" >
            </div>
        </div>
		
		<div class="layui-form-item layui-col-md12">
            <label class="layui-form-label">项目联络人</label>
            <div class="input-group layui-col-md2" style="float: left">
                <input type="text" class="layui-input" name="contact_person" placeholder="项目联络人" value="{$detail.contact_person}" >
            </div>


            <label class="layui-form-label layui-col-md-offset1">联络人电话</label>
            <div class="input-group layui-col-md2" style="float: left">
                <input type="text" class="layui-input" name="contact_phone" placeholder="联络人电话" value="{$detail.contact_phone}" >
            </div>
        </div>


        <div class="layui-form-item layui-col-md12">
            <a class="layui-form-label" title="帮办代办员及联系电话" href="javascript:;">帮办代办员及联系电话:</a>
            <div class="input-group layui-col-md2" style="float: left">
                <input type="text" class="layui-input" name="agent" placeholder="帮办代办员及联系电话" value="{$detail.agent}" >
            </div>
        </div>

        <!--图文模型&单页模型-->
        <div class="layui-form-item" >
            <a class="layui-form-label" title="主要建设内容及规模" href="javascript:;">*主要建设内容及规模:</a>
            <div class="layui-col-md6">
                <textarea id="content"  >{$detail.content}</textarea>
            </div>
        </div>

        <div class="layui-form-item" >
            <a class="layui-form-label" title="需提请协调事项" href="javascript:;">需提请协调事项:</a>
            <div class="layui-col-md6">
                <textarea name="signRemark" class="layui-textarea">{$detail.signRemark}</textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">备注:</label>
            <div class="layui-col-md6">
                <textarea name="remark" placeholder="备注" class="layui-textarea">{$detail.remark}</textarea>
            </div>
        </div>

        <input type="hidden" name="id" value="{$detail.id}">

        <input type="hidden" name="library" value="{$detail.library}">
    </form>

</div>
<div class="add_button">
    <div class="layui-form-item">
        <div class="layui-col-md-offset1">
            <!--<a type="button" class="layui-btn layui-btn-primary" href="{:URL('project/index/index')}?library={$library}" >取消</a>-->
            <button type="button" class="layui-btn layui-btn-primary" onclick="window.history.go(-1);" >取消</button>
            <button type="button" class="layui-btn" id="newsave" >保存</button>
        </div>
    </div>
</div>
<script src="/static/js/location.js"></script>
<script>
    var library = {$library};
    var newModal = new yii.modal();
    layui.extend({
        tinymce: '/static/tinymce/tinymce'
    });
    layui.use(['form','tinymce','laydate','transfer'], function() {
        var form = layui.form
            , layer = layui.layer;
        var tinymce = layui.tinymce;
        var transfer = layui.transfer;
        var laydate = layui.laydate;
        //责任单位
        var duty_unit = {$duty_unit};
        var account= {$account};
        // //责任单位
        transfer.render({
            elem: '#duty_unit'
            ,id:'duty_unit'
            ,data: duty_unit
            ,title: ['全选', '全选']
            ,showSearch: true
            ,height:200
            ,value:{$duty_unit_k}
        }),

            //显示搜索框
            transfer.render({
                elem: '#duty_person'
                ,id:'duty_person'
                ,data: account
                ,title: ['全选', '全选']
                ,showSearch: true
                ,height:200
                ,value:{$duty_person_k}
            }),

            //显示搜索框
            transfer.render({
                elem: '#leader'
                ,id:'leader'
                ,data: account
                ,title: ['全选', '全选']
                ,showSearch: true
                ,height:200
                ,value:{$leader_k}
            })

        // lay('.test-item111').each(function(){
        //     laydate.render({
        //         elem: this
        //         ,trigger: 'click'
        //     });
        // });

        tinymce.render({
            elem:'#content',
            height: 600,
            images_upload_handler: function (blobInfo, succFun, failFun) {
                var xhr, formData;
                var file = blobInfo.blob();//转化为易于理解的file对象
                xhr = new XMLHttpRequest();
                xhr.withCredentials = false;
                xhr.open('POST', "{:URL('/common/upload/textUpload')}");
                xhr.onload = function() {
                    var json;
                    json = JSON.parse(xhr.responseText);
                    succFun(json.path);
                };
                formData = new FormData();
                formData.append('file', file, file.name );//此处与源文档不一样
                xhr.send(formData);
            }
        },(opt, edit) => {});

        function eachvalue(data){
            var newvalue = '';
            $.each(data,function (index,value) {
                newvalue+=value.title+";";
            });
            return newvalue;
        };

        $("#newsave").click(function () {
            var content = tinymce.get('#content').getContent();
            var duty_unit = transfer.getData('duty_unit');
            var duty_person = transfer.getData('duty_person');
            var leader = transfer.getData('leader');
            var duty_unit_v = eachvalue(duty_unit);
            var duty_person_v = eachvalue(duty_person);
            var leader_v = eachvalue(leader);
            var data = $("form[name='layui-form']").serializeArray();
            data.push({name: "content", value: content});
            data.push({name: "duty_unit", value: duty_unit_v});
            data.push({name: "duty_person", value: duty_person_v});
            data.push({name: "leader", value: leader_v});
            $.ajax({
                type:'post',
                url:"{:URL('project/index/save')}",
                data:data,
                dataType:'JSON',
                success:function (res) {
                    if(res.code!=0){
                        layer.alert(res.msg);
                    }else{
                        window.history.go(-1);
                        // window.location.href = "{:URL('project/index/index')}?library="+library;
                    }
                },
                error:function (res) {
                }
            });
        });

        layui.form.render('select');
        form.render();
    });


    //文件页面
    $("#upload").click(function () {
        $(newModal.getid()).show();
        newModal.initialization({
            url: "{:URL('common/upload/index')}",
            type: "post",
            data:{
                type:'detail'
            }
        });
    });

    newModal.on("upload",function(data){
        var images = '';
        $(newModal.getid()).find("#data-area .newimages .active img").each(function () {
            images = $(this).attr('src');
            return false
        })
        $(newModal.getid()).hide();
        //$(".modal-backdrop").remove();
        //$('#nowMainProjectDataForm').modal('hide');
        $(newModal.getid()).find(".modal").hide();
        $("#thumb").val(images);
        $(".config_img").attr("src",images)
    });
</script>

</body>
</html>